<template>
    <div>
        <van-row class="editor-box-tit background-fff">
            <van-col span="8">
                <img class="center-jt" src="../../assets/image/center/icon_return.png" alt="" @click="$router.back(-1)">
            </van-col>
            <van-col span="8" class="text-align-c color-3 font-3">
                隐私设置
            </van-col>
            <van-col span="8" class="text-align-r color-3 font-2">
                <span class="wancheng"></span>
            </van-col>
        </van-row>
        <div class="ziliao1 clearfix background-fff">
            <ul class="clearfix">
                <li>
                    <label class="fl font-3">打赏隐私</label>
                    <van-switch class="fr vanSwitch" v-model="dsChecked" size=".8rem" @input="isSwitch" />
                </li>
                <li>
                    <label class="fl  font-3">排行榜神秘人</label>
                    <van-switch class="fr vanSwitch" v-model="phChecked" size=".8rem" @input="isSwitch1" />
                </li>
            </ul>
        </div>
    </div>
</template>
<script>
    import apiHttp from '../../api/index'
export default {
    data(){
        return{
            dsChecked:false,
            phChecked:false,
            geschenkeStatus:'',//打赏礼物设置隐私状态
            fortunelisteStatus:'',//财富榜设置隐私状态
        }
    },
    //页面加载
    mounted:function(){
        this.getUserInstall();

    },
    methods:{
        //查询设置状态
        getUserInstall(){
            let that = this;
            apiHttp.apiSetting.getUserInstall('',resp=>{
                if(resp.code==200){
                    that.geschenkeStatus = resp.data.geschenkeStatus;
                    that.fortunelisteStatus = resp.data.fortunelisteStatus;
                    if(that.geschenkeStatus=='1'){
                        that.dsChecked=true
                    }
                    if(that.fortunelisteStatus=='1'){
                        that.phChecked=true;
                    }
                }else {
                    Toast(resp.message)
                }

            })
        },

        //打赏隐私设置
        isSwitch(){
            let that = this;

            if(that.dsChecked==true){
                that.geschenkeStatus='1';//开启
                that.updateGeschenkeStatus();
            }
            if(that.dsChecked==false){
                that.geschenkeStatus='0';//关闭
                that.updateGeschenkeStatus();
            }

        },

        //财富排行榜隐私设置
        isSwitch1(){
            let that = this;

            if(that.phChecked==true){
                that.fortunelisteStatus='1';//开启
                that.updateFortunelisteStatus();
            }
            if(that.phChecked==false){
                that.fortunelisteStatus='0';//关闭
                that.updateFortunelisteStatus();
            }
        },
        //会员修改打赏隐私设置状态
        updateGeschenkeStatus(){
            let that = this;
            apiHttp.apiSetting.updateGeschenkeStatus(that.geschenkeStatus,'',resp=>{
                if(resp.code==200){
                    console.log(resp.message);
                }else {
                    console.log(resp.message);
                }
            })
        },

        //会员修改财富榜单隐私设置状态
        updateFortunelisteStatus(){
            let that = this;
            apiHttp.apiSetting.updateFortunelisteStatus(that.fortunelisteStatus,'',resp=>{
                if(resp.code==200){
                    console.log(resp.message);
                }else {
                    console.log(resp.message);
                }
            })
        }

    }
}
</script>

<style scoped>
.ziliao1 li {
    height: 1.8rem;
    line-height: 1.8rem;
    color: #333;
    font-size: .52rem;
    border-bottom: #eeeeee solid .02rem;
    padding: 0 .6rem;
}
.van-icon-arrow{
    margin-top: .6rem;
    margin-left: .4rem;
}
.van-switch--on{
    background-color: #D84E4D;
}
.vanSwitch{
    margin-top: .4rem;
}
</style>

